/**
 * =========================================================================
 *  Copyright 2010 NCS Pte. Ltd. All Rights Reserved
 *
 *  This software is confidential and proprietary to NCS Pte. Ltd. You shall
 *  use this software only in accordance with the terms of the license
 *  agreement you entered into with NCS.  No aspect or part or all of this
 *  software may be reproduced, modified or disclosed without full and
 *  direct written authorisation from NCS.
 *
 *  NCS SUPPLIES THIS SOFTWARE ON AN "AS IS" BASIS. NCS MAKES NO
 *  REPRESENTATIONS OR WARRANTIES, EITHER EXPRESSLY OR IMPLIEDLY, ABOUT THE
 *  SUITABILITY OR NON-INFRINGEMENT OF THE SOFTWARE. NCS SHALL NOT BE LIABLE
 *  FOR ANY LOSSES OR DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
 *  MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 *
 *  Change Revision
 * -------------------------------------------------------------------------
 *  Version    Remarks
 * =========================================================================
 */
package canglang.scan.user.service.impl;

import java.util.List;

import canglang.scan.core.base.pagination.PaginatedListHelper;
import canglang.scan.user.dao.UserDAO;
import canglang.scan.user.model.UserModel;
import canglang.scan.user.service.UserManager;
import canglang.scan.user.to.SearchTO;

/**
 * 
 */
@SuppressWarnings("unchecked")
public class UserManagerImpl implements UserManager{
    private UserDAO userDAO;
    
    
    /**
     * @param userDAO the userDAO to set
     */
    public void setUserDAO (UserDAO userDAO) {
        this.userDAO = userDAO;
    }

    public PaginatedListHelper search(PaginatedListHelper helper,SearchTO searchTO){
        int count = userDAO.searchCount(searchTO);
        helper.setFullListSize(count);
        List list = userDAO.searchList(helper, searchTO);
        helper.setList(list);
        return helper;
    }
    
    public UserModel addUser(UserModel userModel){
        userDAO.addUser(userModel);
        return this.getUser(userModel.getUserId());
    }
    
    public UserModel getUser(String userId){
        return userDAO.getUser(userId);
    }
    
    public UserModel saveUser(UserModel userModel){
        return userDAO.saveUser(userModel);
    }   
    
    public void deleteUser(String userId){
         userDAO.deleteUser(userId);
    }   

}
